import Mock from 'mockjs';
import system from '../data/system.js';
import user from '../data/user.js';
import role from '../data/role.js';
import permission from '../data/permission.js';
import runtime_config from "./config";
import dict from "../data/dict.js";
import dept from "../data/dept.js";
import emp from '../data/emp.js';
import client from '../data/client.js';

import md from '../data/md.js';
import fj from '../data/fj.js';
import sb from '../data/sb.js';
import kh from '../data/kh.js';
import hy from '../data/hy.js';
import hyt from '../data/hyt.js';
import sp from '../data/sp.js';
import dd from '../data/dd.js';

let baseURL = runtime_config[process.env.NODE_ENV].path;

let businessDataArray = [
	system, user, role, permission,dept,emp,dict, client,
	md, fj, sb, kh, hy, hyt, sp, dd
];

for (let index in businessDataArray) {
	let itemDataArray = businessDataArray[index];
	for (let jndex in itemDataArray) {
		let dataObject = itemDataArray[jndex];
		
		Mock.mock(baseURL+dataObject.key, dataObject.method, () => {
			if ("function" === typeof dataObject.data) {
				return dataObject.data();
			}
			return dataObject.data;
		});
	}
}
console.log("adsfasdfasdfasdfasdf");
console.log(Mock._mocked);